package com.migo.utils;

public class PhoneMassage {

    private static ThreadLocal tl = new ThreadLocal();

    public static PhoneMassage getPhoneMassage() {
        PhoneMassage phoneMassage = null;
        if (tl.get() == null) {
            phoneMassage = new PhoneMassage();
            tl.set(phoneMassage);
        } else {
            Object object = tl.get();
            phoneMassage = (PhoneMassage) object;
        }
        return phoneMassage;
    }

    /**
     * 产生随机位数的验证码
     *
     * @return int：SMSCode
     * @throws Exception
     * @author 陈涛
     */
    public static String createSMSCode() throws Exception {

        String str = "";

        str += (int) (Math.random() * 9 + 1);

        for (int i = 0; i < 5; i++) {

            str += (int) (Math.random() * 10);

        }

        int num = Integer.parseInt(str);

        return num + "";
    }


}
